package com.froggushka.api.onehourtranslation;

/*
Copyright (c) 2011 Froggushka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/


//FIXME: the data from the API is inconsistent according to the documentation  example there is distinction between 
// English UK (en-uk) and English US (en-us), however the data for language source only returns the "english" making it impossible to match exactly
// See http://www.onehourtranslation.com/resources/remote-api/supported-languages/ for language mappings
public enum LanguageEnum
{
  ALBANIAN("Albanian","sq-al"),
  ARABIC("Arabic","ar-sa"),
  BENGALI("Bengali","bn-bd"),
  BOSNIAN("Bosnian","bs-ba"),
  BULGARIAN("Bulgarian","bg-bg"),
  CATALAN("Catalan","ca-es"),
  CHINESE_CANTONESE("Chinese Cantonese","zh-cn-yue"),
  //CHINESE_MANDARIN_SIMPLIFIED("Chinese Mandarin-Simplified","zh-cn-cmn-s"),
  CHINESE_MANDARIN_SIMPLIFIED("Chinese","zh-cn-cmn-s"),
  CHINESE_MANDARIN_TRADITIONAL("Chinese Mandarin-Traditional","zh-cn-cmn-t"),
  CROATIAN("Croatian","hr-hr"),
  CHECH("Czech","cs-cz"),
  DANISH("Danish","da-dk"),
  DARI("Dari","fa-af"),
  DUTCH("Dutch","nl-nl"),
  ENGLISH_UK("English UK","en-uk"),
  //ENGLISH_US("English US","en-us"),
  ENGLISH_US("English","en-us"),
  ESTONIAN("Estonian","et-ee"),
  FARSI("Farsi","fa-ir"),
  FINNISH("Finnish","fi-fi"),
  FRENCH("French","fr-fr"),
  FRENCH_CANADIAN("French Canadian","fr-ca"),
  GEORGIAN("Georgian","ka-ge"),
  GERMAN("German","de-de"),
  GREEK("Greek","el-gr"),
  HEBREW("Hebrew","he-il"),
  HINDI("Hindi","hi-in"),
  HUNGARIAN("Hungarian","hu-hu"),
  INDONESIAN("Indonesian","id-id"),
  ITALIAN("Italian","it-it"),
  JAPANESE("Japanese","jp-jp"),
  KAZAKH("Kazakh","kk-kz"),
  KHMER("Khmer","km-kh"),
  KOREAN("Korean","ko-kp"),
  LAO("Lao","lo-la"),
  LATVIAN("Latvian","lv-lv"),
  LITHUANIAN("Lithuanian","lt-lt"),
  MACEDONIAN("Macedonian","mk-mk"),
  MALAY("Malay","ms-my"),
  NORWEGIAN("Norwegian","no-no"),
  PASHTO("Pashto","ps"),
  POLISH("Polish","pl-pl"),
  PORTUGUESE_BRAZIL("Portuguese Brazil","pt-br"),
  //PORTUGUESE_PORTUGAL("Portuguese Portugal","pt-pt"),
  PORTUGUESE_PORTUGAL("Portuguese","pt-pt"),
  ROMANIAN("Romanian","ro-ro"),
  RUSSIAN("Russian","ru-ru"),
  SERBIAN("Serbian","sr-rs"),
  SLOVAK("Slovak","sk-sk"),
  SLOVENIAN("Slovenian (Slovene)","sl-si"),
  SPANISH("Spanish","es-es"),
  SPANISH_LATIN_AMERICA("Spanish Latin-America","es-ar"),
  SWEDISH("Swedish","sv-se"),
  TAGALOG("Tagalog","tl-ph"),
  TAMIL("Tamil","ta-in"),
  THAI("Thai","th-th"),
  TURKISH("Turkish","tr-tr"),
  UKRAINIAN("Ukrainian","uk-ua"),
  URDU("Urdu","ur"),
  UZBEK("Uzbek","uz-uz"),
  VIETNAMESE("Vietnamese","vi-vn"),
  UNKNOWN("Unknown ", "unknown") ;
  
  private final String m_strLanguage;
  private final String m_strLanguageCode;

  private LanguageEnum(String p_strLanguage, String p_strLanguageCode)
  {
    m_strLanguage = p_strLanguage;
    m_strLanguageCode = p_strLanguageCode;
  }

  public String getLanguage()
  {
    return m_strLanguage;
  }
  
  public String getLanguageCode()
  {
    return m_strLanguageCode;
  }
 
  
  public static LanguageEnum getLanguageEnumFromCode(String p_strLanguageCode)
  {
    for(LanguageEnum currentEnum  : LanguageEnum.values())
    {
      if(currentEnum.getLanguageCode().equalsIgnoreCase(p_strLanguageCode))
      {
        return currentEnum;
      }
    }
    
    return UNKNOWN;
  }
  
  public static LanguageEnum getLanguageEnumFromLanguage(String p_strLanguageCode)
  {
    for(LanguageEnum currentEnum  : LanguageEnum.values())
    {
      if(currentEnum.getLanguage().equalsIgnoreCase(p_strLanguageCode))
      {
        return currentEnum;
      }
    }
    
    return UNKNOWN;
  }
}

